package com.example.controller;


import com.example.common.Result;
import com.example.service.VoucherOrderService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * <p>
 * 优惠券订单
 * </p>
 *
 * @author 虎哥
 * @since 2021-12-22
 */
@RestController
@RequestMapping("/voucher-order")
public class VoucherOrderController {
    @Resource
    private VoucherOrderService voucherOrderService;

    /**
     * 优惠券秒杀——超卖问题
     *
     * @param voucherId
     * @param session
     * @return
     */
    @PostMapping("seckill/{id}")
    public Result seckillVoucher(@PathVariable("id") Long voucherId, HttpSession session) {

        return voucherOrderService.seckillVoucher(voucherId, session);
    }

    /**
     * 优惠券秒杀——一人一单
     *
     * @param voucherId
     * @param session
     * @return
     */
    @PostMapping("seckill02/{id}")
    public Result seckillVoucher02(@PathVariable("id") Long voucherId, HttpSession session) {

        return voucherOrderService.seckillVoucher03(voucherId, session);
    }
}
